package com.yzd.learnjava.containers;

import java.util.LinkedList;
import java.util.Stack;

import com.yzd.learnjava.util.Print;

public class Stacks {
	public static void main(String[] args) {
		Stack<String> stack = new Stack<String>();
		for(Month m : Month.values()) {
			stack.push(m.toString());
		}
		Print.print("stack = " + stack);
		
		stack.addElement("The last line");
		Print.print("ekement 5 = " + stack.elementAt(5));
		Print.print("pop elements : ");
		while(!stack.isEmpty()) {
			Print.printnb(stack.pop() + ", ");
		}
		Print.print();
		
		LinkedList<String> lstack = new LinkedList<String>();
		for(Month month : Month.values()) {
			lstack.addFirst(month.toString());
		}
		Print.print("lstack = " + lstack);
		while(!lstack.isEmpty()) {
			Print.printnb(lstack.removeLast() + ", ");
		}
		Print.print();
		
		
		com.yzd.learnjava.holding.Stack<String> stack2 = new com.yzd.learnjava.holding.Stack<String>();
		for(Month m : Month.values()) {
			stack2.push(m.toString());
		}
		Print.print("stack2 = " + stack2);
		while(!stack2.isEmpty()) {
			Print.printnb(stack2.pop() + ", ");
		}
		
	}
}
enum Month{
	JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, OCTOBER, NOVENBER
}
